//
//  ViewController.m
//  13-Homework
//
//  Created by dllo on 16/8/1.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ViewController.h"
#import "FoundPageModel.h"
#import "CusTableViewCell.h"
#import "ZHWCycleView.h"
#define kTableViewReuse @"reuse"
#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height
@interface ViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *foundPageArray;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.foundPageArray = [NSMutableArray array];
    NSArray *array = @[@"1", @"2", @"3", @"4"];
    ZHWCycleView *cycleView = [[ZHWCycleView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, 200)];
    [cycleView setImagesWithArray:array];
    _tableView.tableHeaderView = cycleView;
    [self getData];
}

- (void)getData {
    NSDictionary *dic = @{@"headImageStr": @"1", @"headText": @"终身美丽的猪", @"time": @"5小时前", @"title": @"关于写作", @"topic": @"想法", @"readCount": @"1212次阅", @"commitCount": @"45评论数", @"likeCount": @"123次喜欢", @"rewardCount": @"2次打赏", @"coverImageStr": @"2"};
    NSDictionary *dic1 = @{@"headImageStr": @"3", @"headText": @"红单", @"time": @"5小时前", @"title": @"阅读", @"topic": @"想法", @"readCount": @"1400次阅", @"commitCount": @"12评论数", @"likeCount": @"199次喜欢", @"rewardCount": @"1次打赏", @"coverImageStr": @"4"};
    NSDictionary *dic2 = @{@"headImageStr": @"5", @"headText": @"水杯", @"time": @"3小时前", @"title": @"真正的沟通高手", @"topic": @"交流", @"readCount": @"1233次阅", @"commitCount": @"22评论数", @"likeCount": @"23次喜欢", @"rewardCount": @"1次打赏", @"coverImageStr": @"6"};
    NSArray *arrSource = @[dic, dic1, dic2];
    for (NSDictionary *dic in arrSource) {
        FoundPageModel *model = [FoundPageModel foundPageModelWithDicitonary:dic];
        [_foundPageArray addObject:model];
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _foundPageArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    CusTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kTableViewReuse];
    cell.foundPageModel = _foundPageArray[indexPath.row];
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
